import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import UserEntity from 'src/entities/user.entity';
import { Repository } from 'typeorm';

@Injectable()
export class UserService {
  constructor(
    @InjectRepository(UserEntity)
    private readonly userRepository: Repository<UserEntity>,
  ){}
  
  /**
   * 获取恋爱清单列表
   * @param ThingName 
   * @param Page 
   * @param PageSize 
   * @returns 
   */
  async getUserList(){
    const list=await this.userRepository
      .createQueryBuilder('user')
      .leftJoinAndSelect('Avatar','avatar','avatar.UserSysID=user.SysID')
      .select(['user.NickName NAme','avatar.AvatarUrl'])
      .where('user.Deleted=0')
      .getRawMany()
    
    return {
      code:0,
      data:{
        list:list
      }
    }
  }
}
